const {
    Mysql
} = require('../tools');
module.exports = async ctx => {
    let {
        openId,
        uid
    } = ctx.query;
    if (!openId) {
        ctx.state.data = {
            code: "002",
            msg: '参数缺失'
        }
    }
    try {
        let sql = `SELECT video.vid,video.type,video.sort,video.title,video.coverImg,video.isVip,buyVideo.id FROM video RIGHT JOIN buyVideo ON video.vid = buyVideo.vid WHERE openId='${openId}' ORDER BY buyVideo.create_time DESC LIMIT 20 `
        let list = await Mysql(sql);
        ctx.state.data = {
            code: '001',
            data: list
        }
    } catch (error) {
        ctx.state.data = {
            code: '002',
            data: '内部错误'
        }
    }
};